/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.smn.domain;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.NamedQuery;

/**
 *
 * @author Abdulaziz
 */
@Entity
public class Share implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
    private String description;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date startDate;
    private String place;
    private int budget;
    private int count;
    private int reward;
    @OneToOne
    private MyUser owner;
    
    transient private List<MyUser> invitedUsers = new ArrayList<MyUser>();
    transient private List<MyUser> acceptedUsers = new ArrayList<MyUser>();

    public List<MyUser> getAcceptedUsers() {
        return acceptedUsers;
    }

    public void setAcceptedUsers(List<MyUser> acceptedUsers) {
        this.acceptedUsers = acceptedUsers;
    }

    
//    private static SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
//    public String getFormattedStartDate() {
//        String formattedDate = "";
//
//        if (startDate != null) {
//            formattedDate = sdf.format(startDate);
//
//        }
//        return formattedDate;
//    }
    
    public MyUser getOwner() {
        return owner;
    }

    public List<MyUser> getInvitedUsers() {
        return invitedUsers;
    }

    public void setInvitedUsers(List<MyUser> invitedUsers) {
        this.invitedUsers = invitedUsers;
    }

    public void setOwner(MyUser owner) {
        this.owner = owner;
    }

    public int getBudget() {
        return budget;
    }

    public void setBudget(int budget) {
        this.budget = budget;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }

    public int getReward() {
        return reward;
    }

    public void setReward(int reward) {
        this.reward = reward;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Share)) {
            return false;
        }
        Share other = (Share) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.smn.domain.Share[ id=" + id + " ]";
    }
}
